{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-05-11T08:09:59.899278Z",
     "start_time": "2024-05-11T08:09:59.884344Z"
    }
   },
   "source": [
    "import os\n",
    "\n",
    "dir = '/home/jz/dataset/fight/test/normal'\n",
    "\n",
    "file_list = os.listdir(dir)\n",
    "file_list"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['fight4_36.mp4',\n",
       " 'fight4_26.mp4',\n",
       " 'fight2_22.mp4',\n",
       " 'fight5_13.mp4',\n",
       " 'fight4_49.mp4',\n",
       " 'fight4_12.mp4',\n",
       " 'fight5_14.mp4',\n",
       " 'fight4_43.mp4',\n",
       " 'fight4_13.mp4',\n",
       " 'fight4_11.mp4',\n",
       " 'fight4_34.mp4',\n",
       " 'fight4_48.mp4',\n",
       " 'fight2_10.mp4',\n",
       " 'fight5_11.mp4',\n",
       " 'fight2_12.mp4',\n",
       " 'fight2_9.mp4',\n",
       " 'fight4_14.mp4',\n",
       " 'fight4_47.mp4',\n",
       " 'fight2_23.mp4',\n",
       " 'fight5_8.mp4',\n",
       " 'fight4_28.mp4',\n",
       " 'fight6_1.mp4',\n",
       " 'fight4_6.mp4',\n",
       " 'fight1_9.mp4',\n",
       " 'fight4_2.mp4',\n",
       " 'fight4_44.mp4',\n",
       " 'fight2_11.mp4',\n",
       " 'fight4_29.mp4',\n",
       " 'fight4_4.mp4',\n",
       " 'fight6_5.mp4',\n",
       " 'fight6_7.mp4',\n",
       " 'fight4_45.mp4',\n",
       " 'fight4_8.mp4',\n",
       " 'fight4_3.mp4',\n",
       " 'fight4_41.mp4',\n",
       " 'fight4_38.mp4',\n",
       " 'fight5_7.mp4',\n",
       " 'fight4_32.mp4',\n",
       " 'fight1_7.mp4',\n",
       " 'fight6_4.mp4',\n",
       " 'fight4_1.mp4',\n",
       " 'fight4_5.mp4',\n",
       " 'fight5_9.mp4',\n",
       " 'fight2_29.mp4',\n",
       " 'fight4_16.mp4',\n",
       " 'fight5_30.mp4',\n",
       " 'fight5_5.mp4',\n",
       " 'fight4_30.mp4',\n",
       " 'fight4_27.mp4',\n",
       " 'fight4_35.mp4',\n",
       " 'fight4_9.mp4',\n",
       " 'fight4_15.mp4',\n",
       " 'fight4_42.mp4',\n",
       " 'fight4_40.mp4',\n",
       " 'fight4_46.mp4',\n",
       " 'fight5_31.mp4',\n",
       " 'fight1_6.mp4',\n",
       " 'fight4_10.mp4',\n",
       " 'fight4_33.mp4',\n",
       " 'fight2_39.mp4',\n",
       " 'fight5_4.mp4',\n",
       " 'fight4_39.mp4',\n",
       " 'fight1_1.mp4',\n",
       " 'fight1_8.mp4',\n",
       " 'fight4_37.mp4',\n",
       " 'fight5_6.mp4',\n",
       " 'fight6_6.mp4',\n",
       " 'fight1_3.mp4',\n",
       " 'fight5_1.mp4',\n",
       " 'fight5_10.mp4',\n",
       " 'fight5_27.mp4',\n",
       " 'fight5_34.mp4',\n",
       " 'fight2_35.mp4',\n",
       " 'fight5_32.mp4',\n",
       " 'fight4_31.mp4',\n",
       " 'fight4_50.mp4',\n",
       " 'fight2_30.mp4',\n",
       " 'fight5_12.mp4',\n",
       " 'fight4_7.mp4',\n",
       " 'fight6_8.mp4',\n",
       " 'fight5_26.mp4',\n",
       " 'fight2_52.mp4']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:10:05.291221Z",
     "start_time": "2024-05-11T08:10:05.276962Z"
    }
   },
   "cell_type": "code",
   "source": [
    "i = 55\n",
    "for file in file_list:\n",
    "    name = str(i)\n",
    "    postfix = file.split('.')[-1]\n",
    "    os.rename(dir + '/' + file, dir + '/' + name + '.' + postfix)\n",
    "    i += 1"
   ],
   "id": "19b6898819fe0a32",
   "outputs": [],
   "execution_count": 11
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:23:48.588312Z",
     "start_time": "2024-05-11T08:23:48.572849Z"
    }
   },
   "cell_type": "code",
   "source": [
    "normal_video_dir = '/home/jz/dataset/fight/test/normal'\n",
    "normal_video_name_list = os.listdir(normal_video_dir)\n",
    "normal_video_name_list.sort()\n",
    "normal_video_name_list\n"
   ],
   "id": "bc1d001ce888c59",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['100.mp4',\n",
       " '101.mp4',\n",
       " '102.mp4',\n",
       " '103.mp4',\n",
       " '104.mp4',\n",
       " '105.mp4',\n",
       " '106.mp4',\n",
       " '107.mp4',\n",
       " '108.mp4',\n",
       " '109.mp4',\n",
       " '110.mp4',\n",
       " '111.mp4',\n",
       " '112.mp4',\n",
       " '113.mp4',\n",
       " '114.mp4',\n",
       " '115.mp4',\n",
       " '116.mp4',\n",
       " '117.mp4',\n",
       " '118.mp4',\n",
       " '119.mp4',\n",
       " '120.mp4',\n",
       " '121.mp4',\n",
       " '122.mp4',\n",
       " '123.mp4',\n",
       " '124.mp4',\n",
       " '125.mp4',\n",
       " '126.mp4',\n",
       " '127.mp4',\n",
       " '128.mp4',\n",
       " '129.mp4',\n",
       " '130.mp4',\n",
       " '131.mp4',\n",
       " '132.mp4',\n",
       " '133.mp4',\n",
       " '134.mp4',\n",
       " '135.mp4',\n",
       " '136.mp4',\n",
       " '55.mp4',\n",
       " '56.mp4',\n",
       " '57.mp4',\n",
       " '58.mp4',\n",
       " '59.mp4',\n",
       " '60.mp4',\n",
       " '61.mp4',\n",
       " '62.mp4',\n",
       " '63.mp4',\n",
       " '64.mp4',\n",
       " '65.mp4',\n",
       " '66.mp4',\n",
       " '67.mp4',\n",
       " '68.mp4',\n",
       " '69.mp4',\n",
       " '70.mp4',\n",
       " '71.mp4',\n",
       " '72.mp4',\n",
       " '73.mp4',\n",
       " '74.mp4',\n",
       " '75.mp4',\n",
       " '76.mp4',\n",
       " '77.mp4',\n",
       " '78.mp4',\n",
       " '79.mp4',\n",
       " '80.mp4',\n",
       " '81.mp4',\n",
       " '82.mp4',\n",
       " '83.mp4',\n",
       " '84.mp4',\n",
       " '85.mp4',\n",
       " '86.mp4',\n",
       " '87.mp4',\n",
       " '88.mp4',\n",
       " '89.mp4',\n",
       " '90.mp4',\n",
       " '91.mp4',\n",
       " '92.mp4',\n",
       " '93.mp4',\n",
       " '94.mp4',\n",
       " '95.mp4',\n",
       " '96.mp4',\n",
       " '97.mp4',\n",
       " '98.mp4',\n",
       " '99.mp4']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 14
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:23:59.997159Z",
     "start_time": "2024-05-11T08:23:59.992617Z"
    }
   },
   "cell_type": "code",
   "source": [
    "fight_video_dir = '/home/jz/dataset/fight/test/fight'\n",
    "fight_video_name_list = os.listdir(fight_video_dir)\n",
    "fight_video_name_list.sort()\n",
    "fight_video_name_list"
   ],
   "id": "9cbb34a1ebcb537b",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1.mp4',\n",
       " '10.mp4',\n",
       " '11.mp4',\n",
       " '12.mp4',\n",
       " '13.mp4',\n",
       " '14.mp4',\n",
       " '15.mp4',\n",
       " '16.mp4',\n",
       " '17.mp4',\n",
       " '18.mp4',\n",
       " '19.mp4',\n",
       " '2.mp4',\n",
       " '20.mp4',\n",
       " '21.mp4',\n",
       " '22.mp4',\n",
       " '23.mp4',\n",
       " '24.mp4',\n",
       " '25.mp4',\n",
       " '26.mp4',\n",
       " '27.mp4',\n",
       " '28.mp4',\n",
       " '29.mp4',\n",
       " '3.mp4',\n",
       " '30.mp4',\n",
       " '31.mp4',\n",
       " '32.mp4',\n",
       " '33.mp4',\n",
       " '34.mp4',\n",
       " '35.mp4',\n",
       " '36.mp4',\n",
       " '37.mp4',\n",
       " '38.mp4',\n",
       " '39.mp4',\n",
       " '4.mp4',\n",
       " '40.mp4',\n",
       " '41.mp4',\n",
       " '42.mp4',\n",
       " '43.mp4',\n",
       " '44.mp4',\n",
       " '45.mp4',\n",
       " '46.mp4',\n",
       " '47.mp4',\n",
       " '48.mp4',\n",
       " '49.mp4',\n",
       " '5.mp4',\n",
       " '50.mp4',\n",
       " '51.mp4',\n",
       " '52.mp4',\n",
       " '53.mp4',\n",
       " '54.mp4',\n",
       " '6.mp4',\n",
       " '7.mp4',\n",
       " '8.mp4',\n",
       " '9.mp4']"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 15
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:27:13.457647Z",
     "start_time": "2024-05-11T08:27:13.443555Z"
    }
   },
   "cell_type": "code",
   "source": [
    "lines = []\n",
    "for file in normal_video_name_list:\n",
    "    line = 'normal/' + file + ' ' + '1'\n",
    "    lines.append(line)\n",
    "    \n",
    "lines"
   ],
   "id": "d59b2e6d76121997",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['normal/100.mp4 1',\n",
       " 'normal/101.mp4 1',\n",
       " 'normal/102.mp4 1',\n",
       " 'normal/103.mp4 1',\n",
       " 'normal/104.mp4 1',\n",
       " 'normal/105.mp4 1',\n",
       " 'normal/106.mp4 1',\n",
       " 'normal/107.mp4 1',\n",
       " 'normal/108.mp4 1',\n",
       " 'normal/109.mp4 1',\n",
       " 'normal/110.mp4 1',\n",
       " 'normal/111.mp4 1',\n",
       " 'normal/112.mp4 1',\n",
       " 'normal/113.mp4 1',\n",
       " 'normal/114.mp4 1',\n",
       " 'normal/115.mp4 1',\n",
       " 'normal/116.mp4 1',\n",
       " 'normal/117.mp4 1',\n",
       " 'normal/118.mp4 1',\n",
       " 'normal/119.mp4 1',\n",
       " 'normal/120.mp4 1',\n",
       " 'normal/121.mp4 1',\n",
       " 'normal/122.mp4 1',\n",
       " 'normal/123.mp4 1',\n",
       " 'normal/124.mp4 1',\n",
       " 'normal/125.mp4 1',\n",
       " 'normal/126.mp4 1',\n",
       " 'normal/127.mp4 1',\n",
       " 'normal/128.mp4 1',\n",
       " 'normal/129.mp4 1',\n",
       " 'normal/130.mp4 1',\n",
       " 'normal/131.mp4 1',\n",
       " 'normal/132.mp4 1',\n",
       " 'normal/133.mp4 1',\n",
       " 'normal/134.mp4 1',\n",
       " 'normal/135.mp4 1',\n",
       " 'normal/136.mp4 1',\n",
       " 'normal/55.mp4 1',\n",
       " 'normal/56.mp4 1',\n",
       " 'normal/57.mp4 1',\n",
       " 'normal/58.mp4 1',\n",
       " 'normal/59.mp4 1',\n",
       " 'normal/60.mp4 1',\n",
       " 'normal/61.mp4 1',\n",
       " 'normal/62.mp4 1',\n",
       " 'normal/63.mp4 1',\n",
       " 'normal/64.mp4 1',\n",
       " 'normal/65.mp4 1',\n",
       " 'normal/66.mp4 1',\n",
       " 'normal/67.mp4 1',\n",
       " 'normal/68.mp4 1',\n",
       " 'normal/69.mp4 1',\n",
       " 'normal/70.mp4 1',\n",
       " 'normal/71.mp4 1',\n",
       " 'normal/72.mp4 1',\n",
       " 'normal/73.mp4 1',\n",
       " 'normal/74.mp4 1',\n",
       " 'normal/75.mp4 1',\n",
       " 'normal/76.mp4 1',\n",
       " 'normal/77.mp4 1',\n",
       " 'normal/78.mp4 1',\n",
       " 'normal/79.mp4 1',\n",
       " 'normal/80.mp4 1',\n",
       " 'normal/81.mp4 1',\n",
       " 'normal/82.mp4 1',\n",
       " 'normal/83.mp4 1',\n",
       " 'normal/84.mp4 1',\n",
       " 'normal/85.mp4 1',\n",
       " 'normal/86.mp4 1',\n",
       " 'normal/87.mp4 1',\n",
       " 'normal/88.mp4 1',\n",
       " 'normal/89.mp4 1',\n",
       " 'normal/90.mp4 1',\n",
       " 'normal/91.mp4 1',\n",
       " 'normal/92.mp4 1',\n",
       " 'normal/93.mp4 1',\n",
       " 'normal/94.mp4 1',\n",
       " 'normal/95.mp4 1',\n",
       " 'normal/96.mp4 1',\n",
       " 'normal/97.mp4 1',\n",
       " 'normal/98.mp4 1',\n",
       " 'normal/99.mp4 1']"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 18
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:27:17.087539Z",
     "start_time": "2024-05-11T08:27:17.082231Z"
    }
   },
   "cell_type": "code",
   "source": [
    "for file in fight_video_name_list:\n",
    "    line = 'fight/' + file + ' ' + '2'\n",
    "    lines.append(line)\n",
    "    \n",
    "lines"
   ],
   "id": "de84570e0b5e27bd",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['normal/100.mp4 1',\n",
       " 'normal/101.mp4 1',\n",
       " 'normal/102.mp4 1',\n",
       " 'normal/103.mp4 1',\n",
       " 'normal/104.mp4 1',\n",
       " 'normal/105.mp4 1',\n",
       " 'normal/106.mp4 1',\n",
       " 'normal/107.mp4 1',\n",
       " 'normal/108.mp4 1',\n",
       " 'normal/109.mp4 1',\n",
       " 'normal/110.mp4 1',\n",
       " 'normal/111.mp4 1',\n",
       " 'normal/112.mp4 1',\n",
       " 'normal/113.mp4 1',\n",
       " 'normal/114.mp4 1',\n",
       " 'normal/115.mp4 1',\n",
       " 'normal/116.mp4 1',\n",
       " 'normal/117.mp4 1',\n",
       " 'normal/118.mp4 1',\n",
       " 'normal/119.mp4 1',\n",
       " 'normal/120.mp4 1',\n",
       " 'normal/121.mp4 1',\n",
       " 'normal/122.mp4 1',\n",
       " 'normal/123.mp4 1',\n",
       " 'normal/124.mp4 1',\n",
       " 'normal/125.mp4 1',\n",
       " 'normal/126.mp4 1',\n",
       " 'normal/127.mp4 1',\n",
       " 'normal/128.mp4 1',\n",
       " 'normal/129.mp4 1',\n",
       " 'normal/130.mp4 1',\n",
       " 'normal/131.mp4 1',\n",
       " 'normal/132.mp4 1',\n",
       " 'normal/133.mp4 1',\n",
       " 'normal/134.mp4 1',\n",
       " 'normal/135.mp4 1',\n",
       " 'normal/136.mp4 1',\n",
       " 'normal/55.mp4 1',\n",
       " 'normal/56.mp4 1',\n",
       " 'normal/57.mp4 1',\n",
       " 'normal/58.mp4 1',\n",
       " 'normal/59.mp4 1',\n",
       " 'normal/60.mp4 1',\n",
       " 'normal/61.mp4 1',\n",
       " 'normal/62.mp4 1',\n",
       " 'normal/63.mp4 1',\n",
       " 'normal/64.mp4 1',\n",
       " 'normal/65.mp4 1',\n",
       " 'normal/66.mp4 1',\n",
       " 'normal/67.mp4 1',\n",
       " 'normal/68.mp4 1',\n",
       " 'normal/69.mp4 1',\n",
       " 'normal/70.mp4 1',\n",
       " 'normal/71.mp4 1',\n",
       " 'normal/72.mp4 1',\n",
       " 'normal/73.mp4 1',\n",
       " 'normal/74.mp4 1',\n",
       " 'normal/75.mp4 1',\n",
       " 'normal/76.mp4 1',\n",
       " 'normal/77.mp4 1',\n",
       " 'normal/78.mp4 1',\n",
       " 'normal/79.mp4 1',\n",
       " 'normal/80.mp4 1',\n",
       " 'normal/81.mp4 1',\n",
       " 'normal/82.mp4 1',\n",
       " 'normal/83.mp4 1',\n",
       " 'normal/84.mp4 1',\n",
       " 'normal/85.mp4 1',\n",
       " 'normal/86.mp4 1',\n",
       " 'normal/87.mp4 1',\n",
       " 'normal/88.mp4 1',\n",
       " 'normal/89.mp4 1',\n",
       " 'normal/90.mp4 1',\n",
       " 'normal/91.mp4 1',\n",
       " 'normal/92.mp4 1',\n",
       " 'normal/93.mp4 1',\n",
       " 'normal/94.mp4 1',\n",
       " 'normal/95.mp4 1',\n",
       " 'normal/96.mp4 1',\n",
       " 'normal/97.mp4 1',\n",
       " 'normal/98.mp4 1',\n",
       " 'normal/99.mp4 1',\n",
       " 'fight/1.mp4 2',\n",
       " 'fight/10.mp4 2',\n",
       " 'fight/11.mp4 2',\n",
       " 'fight/12.mp4 2',\n",
       " 'fight/13.mp4 2',\n",
       " 'fight/14.mp4 2',\n",
       " 'fight/15.mp4 2',\n",
       " 'fight/16.mp4 2',\n",
       " 'fight/17.mp4 2',\n",
       " 'fight/18.mp4 2',\n",
       " 'fight/19.mp4 2',\n",
       " 'fight/2.mp4 2',\n",
       " 'fight/20.mp4 2',\n",
       " 'fight/21.mp4 2',\n",
       " 'fight/22.mp4 2',\n",
       " 'fight/23.mp4 2',\n",
       " 'fight/24.mp4 2',\n",
       " 'fight/25.mp4 2',\n",
       " 'fight/26.mp4 2',\n",
       " 'fight/27.mp4 2',\n",
       " 'fight/28.mp4 2',\n",
       " 'fight/29.mp4 2',\n",
       " 'fight/3.mp4 2',\n",
       " 'fight/30.mp4 2',\n",
       " 'fight/31.mp4 2',\n",
       " 'fight/32.mp4 2',\n",
       " 'fight/33.mp4 2',\n",
       " 'fight/34.mp4 2',\n",
       " 'fight/35.mp4 2',\n",
       " 'fight/36.mp4 2',\n",
       " 'fight/37.mp4 2',\n",
       " 'fight/38.mp4 2',\n",
       " 'fight/39.mp4 2',\n",
       " 'fight/4.mp4 2',\n",
       " 'fight/40.mp4 2',\n",
       " 'fight/41.mp4 2',\n",
       " 'fight/42.mp4 2',\n",
       " 'fight/43.mp4 2',\n",
       " 'fight/44.mp4 2',\n",
       " 'fight/45.mp4 2',\n",
       " 'fight/46.mp4 2',\n",
       " 'fight/47.mp4 2',\n",
       " 'fight/48.mp4 2',\n",
       " 'fight/49.mp4 2',\n",
       " 'fight/5.mp4 2',\n",
       " 'fight/50.mp4 2',\n",
       " 'fight/51.mp4 2',\n",
       " 'fight/52.mp4 2',\n",
       " 'fight/53.mp4 2',\n",
       " 'fight/54.mp4 2',\n",
       " 'fight/6.mp4 2',\n",
       " 'fight/7.mp4 2',\n",
       " 'fight/8.mp4 2',\n",
       " 'fight/9.mp4 2']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 19
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-11T08:28:51.348681Z",
     "start_time": "2024-05-11T08:28:51.339064Z"
    }
   },
   "cell_type": "code",
   "source": [
    "with open('/home/jz/dataset/fight/test/annotation', 'w') as f:\n",
    "    for line in lines:\n",
    "        f.write(line)\n",
    "        f.write('\\n')"
   ],
   "id": "cc09765b63dfbd10",
   "outputs": [],
   "execution_count": 22
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
